home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / EX2_4.C < prev    next >
C/C++ Source or Header  |  1992-08-20  |  2KB  |  37 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12.  
  13. #include <cool/String.h>            // Include CoolString header file
  14.  
  15. int main (void) {
  16.   CoolString s1 = "Hello";            // Create CoolString object
  17.   cout << "s1 reads: " << s1 << "\n";        // Display CoolString value
  18.   cout << "s1 has " << strlen (s1) << " characters\n"; // Display char count
  19.   s1 = s1 + " " + "world!";                   // Concatenate characters
  20.   cout << "s1 reads: " << s1 << "\n";               // Display CoolString value
  21.   cout << "s1 has " << strlen (s1) << " characters\n"; // Display char count
  22.   s1.reverse ();                       // Reverse character order
  23.   cout << "s1 backwards reads: " << s1 << "\n";           // Output reversed CoolString
  24.   s1.reverse ();                       // Get normal ordering back
  25.   cout << "s1 upper case: " << upcase (s1) << "\n";    // Display uppercase value
  26.   cout << "s1 lower case: " << downcase (s1) << "\n";  // Display downcase value
  27.   cout << "s1 capitalized: " << capitalize (s1) << "\n"; // Display capitalized value
  28.   s1.insert ("Oh, ", 0);                 // Insert at start of CoolString
  29.   cout << "s1 reads: " << s1 << "\n";             // Display CoolString value
  30.   s1.replace ("Goodbye", 4, 9);                 // Replace `hello' with `goodbye'
  31.   cout << "s1 reads: " << s1 << "\n";             // Display CoolString value
  32.   s1.remove (4, 12);                     // Remove `goodbye'
  33.   cout << "s1 reads: " << s1 << "\n";             // Display CoolString value
  34.   return (0);                         // Exit with OK status
  35. }
  36.  
  37.